import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import path from 'path'

// https://vitejs.dev/config/
export default defineConfig({
  resolve: {
    alias: {
      '@/assets': path.resolve(__dirname, 'src/assets'),
      '@': path.resolve(__dirname, './src')
    },
  },
  server: {
    port: 3000, // 指定端口号
    host: 'localhost', // 默认值是 localhost，可以根据需要改为 0.0.0.0 以允许外部访问
    open: true, // 设置为 true 会在服务启动时自动打开浏览器
    proxy: {
      "/api": {
        // target: "http://127.0.0.1:6111",
        // // target: "http://60.28.16.175:17006/api",
        // changeOrigin: true,
        // rewrite: (path) => path.replace(/^\/api/, ""),
        target: 'http://192.168.110.35:30009',
        changeOrigin: true,
        pathRewrite: {
          '^/api': ''
        }
      }
    },
  },
  plugins: [vue(),AutoImport({
    resolvers: [ElementPlusResolver()],
  }),
  Components({
    resolvers: [ElementPlusResolver()],
  }),],
  base: './'
})
